<?php
Zend_Loader::loadClass("Application_Ajax_Server_Function");
class GetMaterialList extends Application_Ajax_Server_Function
{
	public function call() {
		Zend_Loader::loadClass('Materials');
		$materiali = new Materials();
		// id è l'id della categoria
		if (!$this->_getParam('id', false)) {
			$recordSet = $materiali->select()->from($materiali, array("id", "name"))
			->where("status > ?", 0)
			->order("name");
		} else {
			$recordSet = $materiali->select()->from($materiali, array("id", "name"))
			->where("id_category = ?", $this->_getParam('id'))
			->where("status > ?", 0)
			->order("name");
		}
		$mats = $materiali->fetchAll($recordSet)->toArray();
		return $mats;
	}
}